<template>

</template>
<script>
export default {
  name: "oauthCallback",
  data() {
    return {
      authCallback: {
        platform: "",
        code: "",
        state: "",
      },
    };
  },
  created() {
    this.authCallback.platform = this.$route.params.platform;
  },
  mounted() {
    var code = this.$utils.getUrlKey("code");
    var state = this.$utils.getUrlKey("state");
    this.authCallback.code = code;
    this.authCallback.state = state;
    //server-side模式
    if (code && typeof code != "undefined") {
      console.log("server-side模式:" + code);
      //获取到token就是已经登录了
      var token = this.$store.getters.token;
      if (token && typeof token != "undefined") {
        this.$router.push("/");
      }
      //未登录则执行登录
      else {
        this.$store
          .dispatch("user/authCodelogin", this.authCallback)
          .then(() => {
            location.reload();
          });
      }
    }
  },
};
</script>

<style>
</style>